/**
 * Copyright (C) 2010-2012 Regis Montoya (aka r3gis - www.r3gis.fr)
 * This file is part of CSipSimple.
 *
 *  CSipSimple is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *  If you own a pjsip commercial license you can also redistribute it
 *  and/or modify it under the terms of the GNU Lesser General Public License
 *  as an android library.
 *
 *  CSipSimple is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with CSipSimple.  If not, see <http://www.gnu.org/licenses/>.
 *  
 *  This file and this file only is also released under Apache license as an API file
 */
package com.cloudptt.api.pjsua2.api;
import com.cloudptt.api.pjsip.api.SipProfileState;
import com.cloudptt.api.pjsip.api.SipCallSession;
import com.cloudptt.api.pjsip.api.MediaState;
import com.cloudptt.api.pjsip.api.SipProfile;

interface IPjsuaService{
	/**
	* Get the current API version
	* @return version number. 1000 x major version + minor version
	* Each major version must be compatible with all versions of the same major version
	*/
	
	int getVersion();

	//Stack control
	/**
	* Start the sip stack
	*/
	void sipStart();
	/**
	* Stop the sip stack
	*/
	void sipStop();
	/**
	* Force to stop the sip service (stack + everything that goes arround stack)
	*/
	void forceStopService();
	/**
	* Restart the sip stack
	*/
	void askThreadedRestart();
	
	//Account control
	/**
	* Add all accounts available in database and marked active to running sip stack (loaded previously using sipStart)
	*/
	//void addAllAccounts();
	
	/**
	* Add a accounts by mdn and puid
	*/
	void addAccount(String svrIp,int port,String num,String pwd,String regJson,float txLevel,float rxLevel);
	
	void setVideoAttr(int videoResolving);
	
	//void setAudioInCall(int callType);
	
	//void unsetAudioInCall();
	
	
	
	/**
	* Remove all accounts from running sip stack (this does nothing in database)
	*/
	void removeAllAccounts();
	void delCurAccount();
	
	//void addBuddy(int mcType,String mcId,String requestLineUri,String xCapStr);
	
	//void insertUserIfLoginSuc();
	
//	boolean isConnectivity();
	
	
	/**
	* remove and add all accounts available in database and marked active
	*/
	//void reAddAllAccounts(String extStr);
	/**
	* Change registration for a given account/profile id (id in database)
	* @param accountId the account for which we'd like to change the registration state
	* @param renew 0 if we don't want to unregister, 1 to renew registration
	*/
	//int setAccountRegistration(int renew,String extStr);

	
	//Call configuration control
	/**
	 * Switch next incoming request to auto answer
	 */
	//void switchToAutoAnswer();
	/**
	 * Ignore next outgoing call request from tel handler processing
	 */
	//void ignoreNextOutgoingCallFor(String number);
	
	//void setCallConfig(in BaseCallConfig config);
	
	/**
	 * Place a call.
	 * 
	 * @param callee The sip uri to call. 
	 * It can also be a simple number, in which case the app will autocomplete.
	 * If you add the scheme, take care to fill completely else it could be considered as a call
	 * to a sip IP/domain
	 * @param accountId The id of the account to use for this call. 
	 * @param options The options you'd like to apply for this calls {@link SipCallSession#OPT_CALL_VIDEO}, {@link SipCallSession#OPT_CALL_EXTRA_HEADERS}
	 */
	int makeCallWithOptions(in String callee,in String called, int callType,in boolean isHaveVideo);
	//int makeWebrtcCall(in int callType,in String toCall,in String called,in boolean isHaveVideo,in String webrtcSdp);
	/**
	 * Answer a call.
	 * 
	 * @param callId The id of the call to answer.
	 * @param status The sip status code you'd like to answer with. 200 to take the call.  400 <= status < 500 if refusing.
	 */
	int answer(String callIdStr, int status,int callType,String called, boolean hasVideo);
	//int answerWebrtcPCall(int callId, int status,int callType,String called,String webrtcSdp);
	/**
	 * Hangup a call.
	 *
	 * @param callId The id of the call to hangup.
	 * @param status The sip status code you'd like to hangup with.
	 */
	int hangup(String callIdStr, int status);
	int reinvite(int callId, int unhold,String extStr,String negoStr);
	int destoryCall(String callIdStr);
	void clearAllCalls();
	void clearResourceForCallEnd(String callIdStr);
	int hold(int callId);
	int floorRequest(String callIdStr,int level,String gNum,String uNum);
	int floorRelease(String callIdStr,int level,String gNum,String uNum);
//	int setGCallRtpExt( String callIdStr, int isGroup, int level, String gNum, String uName);
	int clearCurGroup(String callIdStr);
	int requestTrans(String callIdStr);
	int releaseTrans(String callIdStr);
	int negotiateGroupRtpRtcpChannel(String callIdStr,String gNum,String uNum);
	int negotiateGroupRtcpChannel(String callIdStr,String gNum,String uNum);
	int negotiateRtpChannel(String callIdStr);
    int negotiateVideoChannel(String callIdStr);

	void requestAudioFocus(boolean isSetSnd);
    void releaseAudioFocus();
    void onVol(int type);
    void setSpeakerphoneOn(boolean on);
	int opAudioMedia(String callIdStr,int opType);
	int opVideoMedia(String callIdStr,int opType);

	void ring(int type,boolean isRing);
	void updateAudioChannel(int callType);
	//int sendDtmf(int callId, int keyCode);
	//int xfer(int callId, in String callee);
	//int xferReplace(int callId, int otherCallId, int options);
	//SipCallSession getCallInfo(int callId);
	SipCallSession[] getCalls();
	String showCallInfosDialog(int callId);
	
	void setNoSnd();
	void setSnd();
	//Media control
	//void setMicrophoneMute(boolean on);
	//void setSpeakerphoneOn(boolean on);
	//void setSpeakerphoneOffLater();
	//void startSoundPlayer(int type);
	//void setBluetoothOn(boolean on);
	//void setHeadsetMicphoneOn(boolean on);
	void confAdjustTxLevel(int port, float value);
	void confAdjustRxLevel(int port, float value);
	/**
	 * Get Rx and Tx sound level for a given port.
	 *
	 * @param port Port id we'd like to have the level
	 * @return The RX and TX (0-255) level encoded as RX << 8 | TX
	 */
	long confGetRxTxLevel(int port);
	void setEchoCancellation(boolean on);
	//void adjustVolume(in SipCallSession callInfo, int direction, int flags);
	//MediaState getCurrentMediaState();
	//int startLoopbackTest();
	//int stopLoopbackTest();
	
	// Record calls
	/**
	 * Start recording of a call to a file.
	 * 
	 * @param callId the call id to start recording of.
     * @param way the way the recording takes
     *  {@link SipManager#BITMASK_IN} => record remote party (what goes out speaker/earpiece)
     *  {@link SipManager#BITMASK_OUT} =>  record self (what comes from micro), 
     * If 0 will record all ways.
	 */
	void startRecording(int callId, int way);
	/**
	 * Stop recording of a call.
	 * 
	 * @param callId the call id to stop recording (of all recording ways)
	 */
	void stopRecording(int callId);
	/**
	 * Is the call being recorded (for at least one way) ?
	 * 
	 * @param callId the call id to get recording status of.
	 * @return true if the call is currently being recorded
	 */
	boolean isRecording(int callId);
	/**
	 * Can the call be recorded ?
	 * 
	 * @param callId the call id to get record capability of.
	 * @return true if it's possible to record the call. 
	 */
	boolean canRecord(int callId);
	
	void startVol(int callId);
	void stopVol(int callId);
	
	// Play files to stream
	/**
	* @param filePath filePath the file to play in stream
	* @param callId the call to play to
	* @param way the way the file should be played 
	* {@link SipManager#BITMASK_IN} =>  send to user (speaker/earpiece)
	*  {@link SipManager#BITMASK_OUT}  => send to remote party (micro), 
	* example : way = 3 : will play sound both ways
	*/
	void playWaveFile(String filePath, int callId, int way);
	
	
	//int sendPocSetting(boolean isActive,int type);
	// SMS
	int sendMessage(int sessionType,int msgType,long len,String msg, String toNumber);
	//int sendTextMessage(String msg, String toNumber);
	//int sendCandidateMsg(int callId,String callee,String candidateMsg);
	int sendSystemMessage(String message);
	int sendSosMessage();
	//int sendLocationMessage(boolean isReport,String locationInfoStr);
	//int setSerialReported(boolean isSerialReport,String mcpttId);
	int sendSubscribe(String uri);
	int sendPublish(String groupNum);
	int setCallGNum(String allCallGNum,String curGroupNum,String sosGroupNum,String selfNum);
	/**
	* start hand shake timer with sip server by METHOD OPTIONS
	*/
	//int startHandShakeTimer(String extStr);
	//void stopHandShakeTimer();
	//int sendOptions();
	
	// Presence
	//void setPresence(int presence, String statusText, long accountId);
	//int getPresence(long accountId);
	//String getPresenceStatus(long accountId);
	
	//Secure
	//void zrtpSASVerified(int callId);
	/**
	 * Revoke a ZRTP SAS
	 */ 
	//void zrtpSASRevoke(int callId);
	// Video
	int updateCallOptions(int callId, in  boolean isChangeCamera,in boolean isHaveVideo);
	
	/**
	 * Get nat type detected by the sip stack
	 * @return String representing nat type detected by the stack. Empty string if nothing detected yet.
	 */
	 String getLocalNatType();
	 
	 boolean isActiveCall();
	 boolean isIncommingCall();
}